<!DOCTYPE html>
<script>
window.x = 42;

function callback2()
{
    return this.x;
}

function registerCallback()
{
    function callback1() {
        return callback2();
    }

    window.parent.registerCallback(callback1);
}
</script>
<body onload="registerCallback()"></body>
